Can't run migrations if using other modules in entities · Issue #383 · mikro 您所在的位置:网站首页 mikro orm Can't run migrations if using other modules in entities · Issue #383 · mikro

Can't run migrations if using other modules in entities · Issue #383 · mikro

2023-04-11 12:02| 来源: 网络整理| 查看: 265

It is "injected" by the application that runs this one (present at runtime), so while it is not installed as a dependency, I have installed the typings as a dev dependency, which can be found here: https://www.npmjs.com/package/@altv/types

Typings are not enough, the error comes from actual import of that "library". What does it mean "injected", how do you do that? You basically need to do the same when running migrations (which you could probably do by adding that "injection" code to the ORM config as that will be required when running the CLI command).

I think the migration maker should just ignore imports that are only used in methods/properties not present with a @Property/@PrimaryKey/[...] decorators.

Well afaik this is just not possible, node (or ts-node) is running the code, and this error comes from it. I do not see a way how we could ignore deps. Not talking that I would see that as unwanted error hiding. Imagine that dependency would be actually needed to run the migration. I can't just ignore what was not found.

Keep in mind that while generated migrations contain only SQL code, what you run is an up method. It can contain other code than just the SQL, you could call queries directly (e.g. to allow running queries conditionally).

edit: do you by any chance use paths mapping in the tsconfig.json for this? maybe you just need to register https://github.com/dividab/tsconfig-paths



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有